package com.bilgeadam.exceptions.program;

import java.io.Closeable;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * 
 * @author Bora SAYINER
 * @since Nov 30, 2014 11:28:53 AM
 * @version 1.0.0
 */
public class Employee implements Closeable {

	private String firstName;
	private String lastName;
	
	public Employee() {
		System.out.println("Constructor");
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) throws IsimHatasi {
		if (firstName.trim().length() >= 3) {
			this.firstName = firstName;
		} else {
			throw new IsimHatasi("Çalışan adı 3 karakterden küçük olamaz");
		}
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	@Override
	public String toString() {
		return "Employee [firstName=" + firstName + ", lastName=" + lastName + "]";
	}

	public void readFile()  {
		File file = new File("/home/developer/Desktop/test");
		try {
			FileReader fileReader = new FileReader(file);
		} catch (FileNotFoundException e) {
			// log alma işlemi yapıldı
			throw new RuntimeException(e.getMessage());
		}
		
	}

	@Override
	public void close() throws IOException {
		System.out.println("Employee closed");
	}

	@Override
	protected void finalize() throws Throwable {
		// TODO Auto-generated method stub
		super.finalize();
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}
